layui.config({
  base: "js/"
}).use(['form', 'layer', 'jquery', 'layedit', 'laydate', 'upload'], function () {
  var form = layui.form(),
    layer = parent.layer === undefined ? layui.layer : parent.layer,
    laypage = layui.laypage,
    layedit = layui.layedit,
    laydate = layui.laydate,
    $ = layui.jquery;

  layui.upload({
    title: '请选择xls或xlsx',
    url: '/api/score/upload',
    success: function(res){
      console.log('result: ', res); //上传成功返回值，必须为json格式
      var result = eval(res);
      if (result.status === 'success') {
        top.layer.msg("数据批量导入成功！");
        layer.closeAll("iframe");
        parent.location.reload();
      }
      else
        layer.msg("数据批量导入失败！");
    }
  });

  form.on("submit(uploadFile)", function (data) {
    console.log(data);
  })

});
